#include "cpu/exec/template-start.h"

#define instr lods

make_helper(concat3(instr, _, SUFFIX)) {
	int source_index, incDec;
	if (DATA_BYTE == 2) {
		source_index = cpu.gpr[R_SI]._16;
	} else {
		source_index = cpu.gpr[R_ESI]._32;
	}

	if (DATA_BYTE == 1) {
		cpu.gpr[R_AL]._8[0] = MEM_R(source_index, R_DS);
	} else if (DATA_BYTE == 2) {
		cpu.gpr[R_AX]._16 = MEM_R(source_index, R_DS);
	} else {
		cpu.gpr[R_EAX]._32 = MEM_R(source_index, R_DS);
	}

	if (cpu.eflags.DF == 0) {
		incDec = DATA_BYTE;
	} else {
		incDec = -DATA_BYTE;
	}

	if (DATA_BYTE == 2) {
		cpu.gpr[R_SI]._16 += incDec;
	} else {
		cpu.gpr[R_ESI]._32 += incDec;
	}
	return 1;
}

#include "cpu/exec/template-end.h"
